﻿<Window x:Class="DemoApplication.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:bh="http://www.brokenhouse.co.uk/wpf"
        xmlns:demos="clr-namespace:DemoApplication.Demos"
        xmlns:diag="clr-namespace:System.Diagnostics;assembly=WindowsBase"
        Title="MainWindow" Height="600" Width="690"
        Background="{DynamicResource BackgroundGradient}">
    
    <Window.Resources>
        <DataTemplate x:Key="ListItemTemplate">
            <TextBlock Text="{Binding Label}" Margin="0,0,0,0"/>
        </DataTemplate>
        
        <CollectionViewSource Source="{Binding AllItems}" x:Key="DemoItemsCollection">
            <CollectionViewSource.GroupDescriptions>
                <PropertyGroupDescription PropertyName="Group"/>
            </CollectionViewSource.GroupDescriptions>
        </CollectionViewSource>

        <SolidColorBrush x:Key="BackgroundGradient" Color="#FFf0f0f0"/>
     

        <Style x:Key="ListViewStyle1" TargetType="{x:Type ListView}">
            <Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.WindowBrushKey}}"/>
            <Setter Property="BorderThickness" Value="1"/>
            <Setter Property="Foreground" Value="#FF042271"/>
            <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto"/>
            <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
            <Setter Property="ScrollViewer.CanContentScroll" Value="true"/>
            <Setter Property="VerticalContentAlignment" Value="Center"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type ListView}">
                        <bh:EdgeScrollViewer Padding="{TemplateBinding Padding}">
                           <ItemsPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
                        </bh:EdgeScrollViewer>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsGrouping" Value="true">
                                <Setter Property="ScrollViewer.CanContentScroll" Value="false"/>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

    </Window.Resources>

    <DockPanel Margin="10">
        <ListView x:Name="ItemsList" 
                  ItemsSource="{Binding Source={StaticResource DemoItemsCollection}}"
                  SelectedItem="{Binding Path=SelectedItem}"
                  BorderThickness="0" Margin="0,0,10,0" Background="Transparent" Width="160"
                  Style="{DynamicResource ListViewStyle1}">
            <ListView.GroupStyle>
                <GroupStyle HidesIfEmpty="True">
                    <GroupStyle.HeaderTemplate>
                        <DataTemplate>
                            <TextBlock Margin="3" FontWeight="Bold" FontSize="15" Text="{Binding Path=Name}"/>
                            <DataTemplate.Triggers>
                                <DataTrigger Binding="{Binding Path=Name}" Value="{x:Null}">
                                    <DataTrigger.Setters>
                                        <Setter Property="Visibility" Value="Collapsed"/>
                                    </DataTrigger.Setters>
                                </DataTrigger>
                            </DataTemplate.Triggers>
                        </DataTemplate>
                    </GroupStyle.HeaderTemplate>
                </GroupStyle>
            </ListView.GroupStyle>
            <ListView.View>
                <GridView>
                    <GridView.ColumnHeaderContainerStyle>
                        <Style TargetType="{x:Type GridViewColumnHeader}">
                            <Setter Property="Visibility" Value="Collapsed"/>
                        </Style>
                    </GridView.ColumnHeaderContainerStyle>
                    <GridViewColumn DisplayMemberBinding="{Binding Path=Label}" Header="Section"  />
                </GridView>
            </ListView.View>
        </ListView>
        
        <Border CornerRadius="2" BorderBrush="#ff000000" BorderThickness="1,1,1,1" SnapsToDevicePixels="True"
                Background="{DynamicResource {x:Static SystemColors.ControlBrushKey}}">
            <Border.Effect>
                <DropShadowEffect BlurRadius="3" Color="#808080" Opacity="0.3"/>
            </Border.Effect>
            <Grid>
                <Border CornerRadius="2" BorderBrush="#ffffffff" BorderThickness="1,1,1,1" SnapsToDevicePixels="True" ClipToBounds="True">
                    <Border.Background>
                        <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0" Opacity="0.05">
                            <GradientStop Color="#3000FF16" Offset="1"/>
                            <GradientStop Color="#0000FF14" Offset="0"/>
                        </LinearGradientBrush>
                    </Border.Background>
                    <Border BorderBrush="#ffffffff" BorderThickness="10,4,10,30" SnapsToDevicePixels="True">
                        <Border.BitmapEffect>
                            <BlurBitmapEffect Radius="30" KernelType="Gaussian"/>
                        </Border.BitmapEffect>
                    </Border>
                </Border>
                <bh:TransitionItemsControl x:Name="ItemsControl" Margin="5"
                                           TransitionInSequence="false"
                                           ItemsSource="{Binding ElementName=ItemsList, Path=Items}"
                                           ActiveItem="{Binding ElementName=ItemsList, Path=SelectedItem, Mode=TwoWay}"
                                           HorizontalContentAlignment="Stretch" VerticalContentAlignment="Top">
                   <!-- <bh:TransitionItemsControl.TransitionEffect>
                        <bh:BlurAndFadeTransitionEffect SpeedRatio="1.5"/>
                    </bh:TransitionItemsControl.TransitionEffect>-->
                    <bh:TransitionItemsControl.ItemTemplate>
                        <DataTemplate>
                            <ScrollViewer x:Name="PART_Viewer" HorizontalScrollBarVisibility="Disabled" 
                                          VerticalScrollBarVisibility="Auto"
                                          HorizontalAlignment="Stretch">
                                <ContentPresenter Content="{Binding .}"/>
                            </ScrollViewer>
                            <DataTemplate.Triggers>
                                <DataTrigger Binding="{Binding IsContentStatic}" Value="true">
                                    <Setter TargetName="PART_Viewer" Property="VerticalScrollBarVisibility" Value="Disabled"/>
                                </DataTrigger> 
                            </DataTemplate.Triggers>
                        </DataTemplate>
                    </bh:TransitionItemsControl.ItemTemplate>
                </bh:TransitionItemsControl>

            </Grid>
        </Border>
    </DockPanel>
</Window>
